package com.irssproject.app.web.action.clustering;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.irssproject.app.bean.main.Usuari;
import com.irssproject.app.service.clustering.iface.ClusteringEngineService;
import com.irssproject.app.utils.Constants;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class ClusteringAction  extends ActionSupport {

	private static final long serialVersionUID = 1L;

	ClusteringEngineService clusteringEngineService;
	
	public void setClusteringEngineService(ClusteringEngineService clusteringEngineService) {
		this.clusteringEngineService = clusteringEngineService;
	}

	List<HashMap<String, String>> clustersListString;
	
	
	
public List<HashMap<String, String>> getClustersListString() {
		return clustersListString;
	}



	public void setClustersListString(List<HashMap<String, String>> clustersListString) {
		this.clustersListString = clustersListString;
	}



	//	private Set<FeedCluster> clustersList;
//	private FeedCluster[] clustersListString;
	public String generarClusters() {
		
		try{

			Map session = ActionContext.getContext().getSession();

			Usuari usuari = (Usuari)session.get(Constants.SESSIO_USUARI_AUTENTICAT);
		
			List<HashMap<String,String>> li = clusteringEngineService.clusteringByLabel(usuari);
			setClustersListString(li);
//			FeedCluster[] f = new FeedCluster[]{};
//			setClustersListString(clustersList.toArray(f));
			
		}catch(Exception e){
			e.printStackTrace();
		}
		
		return SUCCESS;

	}


	
}
